<?php
/*
 * This file is part of SoftSite.
 *
 * (c) 2012 Steve Tredinnick
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 *
 *
 * @package softsite
 * @author  Steve Tredinnick <steve.tredinnick@gmail.com>
 */

namespace Controllers;

use Lib\Forms\Elements;

class TestForm_Controller extends \Classes\BaseController
{

    public function index()
    {
        $this->form->setFormName("TestForm");
        $this->form->setFormMethod("post");
        $this->form->OpenFieldSet("SteveTestFieldSet", "Form Controls Test Page");
        $this->BuildTestButton();
        $this->BuildTestCheckbox();
        $this->BuildTestColor();
        $this->BuildTestDate();
        $this->BuildTestDateTime();
        $this->BuildTestDateTimeLocal();
        $this->BuildTestEmail();
        $this->BuildTestFile();
        $this->BuildTestHidden();
        $this->BuildTestImage();
        $this->BuildTestMonth();
        $this->BuildTestMonth();
        $this->BuildTestNumber();
        $this->BuildTestPassword();
        $this->BuildTestRadio();
        $this->BuildTestRange();
        $this->BuildTestReset();
        $this->BuildTestSearch();
        $this->BuildTestSubmit();
        $this->BuildTestTelephone();
        $this->BuildTestText();
        $this->BuildTestTime();
        $this->BuildTestUrl();
        $this->BuildTestWeek();
        $this->form->CloseFieldSet();
        $this->RenderFormToTemplate();
        $this->DisplayView();
    }

    private function BuildTestButton()
    {
        $this->form->OpenFieldSet("ButtonFieldSet", "Button Test");
        $button = new Elements\ButtonElement();
        $button->SetAutoFocus();
        //$button->SetDisabled();
        $button->SetFormAction("http://localhost");
        $button->SetFormMethod("post");
        $button->SetFormNoValidate();
        $button->SetFormTarget("_top");
        $button->SetImage("image");
        $button->SetName("SteveTestButtonName");
        $button->SetText("SteveTestButtonText");
        $button->SetType("submit");
        $button->SetValue("SteveTestButtonValue");
        $this->form->AddElement($button);
        $this->form->CloseFieldSet();
    }

    private function BuildTestCheckbox()
    {
        $this->form->OpenFieldSet("CheckBoxFieldSet", "CheckBox Test");
        $checkbox = new Elements\CheckBoxElement("testcheckbox");
        $checkbox->SetName("TestCheckBox");
        $checkbox->SetChecked(false);
        $checkbox->SetLabel("Test Checkbox Label");
        $checkbox->SetText("Test Checkbox Text");
        $this->form->AddElement($checkbox);
        $this->form->CloseFieldSet();
    }

    private function BuildTestColor()
    {
        $this->form->OpenFieldSet("ColorFieldSet", "Color Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestWeek()
    {
        $this->form->OpenFieldSet("WeekFieldSet", "Week Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestUrl()
    {
        $this->form->OpenFieldSet("UrlFieldSet", "URL Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestTime()
    {
        $this->form->OpenFieldSet("TImeFieldSet", "Time Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestText()
    {
        $this->form->OpenFieldSet("TextFieldSet", "Text Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestTelephone()
    {
        $this->form->OpenFieldSet("TelephoneFieldSet", "Telephone Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestSubmit()
    {
        $this->form->OpenFieldSet("SubmitFieldSet", "Submit Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestSearch()
    {
        $this->form->OpenFieldSet("SearchFieldSet", "Search Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestReset()
    {
        $this->form->OpenFieldSet("ResetFieldSet", "Reset Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestRange()
    {
        $this->form->OpenFieldSet("RangeFieldSet", "Range Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestRadio()
    {
        $this->form->OpenFieldSet("RasioFieldSet", "Radio Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestPassword()
    {
        $this->form->OpenFieldSet("PasswordFieldSet", "Password Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestNumber()
    {
        $this->form->OpenFieldSet("NumberFieldSet", "Number Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestMonth()
    {
        $this->form->OpenFieldSet("MonthFieldSet", "Month Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestImage()
    {
        $this->form->OpenFieldSet("ImageFieldSet", "Image Test");

        $image = new Elements\ImageElement("testImage");
        $image->SetSrc("http://localhost/projects/softsite/views/testform/images/testimage.jpg");
        $image->SetWidth("416");
        $image->SetHeight("333");
        $this->form->AddElement($image);
        $this->form->CloseFieldSet();
    }

    private function BuildTestHidden()
    {
        $this->form->OpenFieldSet("HiddenFieldSet", "Hidden Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestFile()
    {
        $this->form->OpenFieldSet("FileFieldSet", "File Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestEmail()
    {
        $this->form->OpenFieldSet("EmailFieldSet", "Email Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestDateTimeLocal()
    {
        $this->form->OpenFieldSet("DateTimeLocalFieldSet", "DateTimeLocal Test");

        $this->form->CloseFieldSet();
    }

    private function BuildTestDate()
    {
        $this->form->OpenFieldSet("DateFieldSet", "Date Test");

       $date = new Elements\DateElement("TestDate");        $this->form->AddElement($date);
       $this->form->CloseFieldSet();
    }

    private function BuildTestDateTime()
    {
        $this->form->OpenFieldSet("DateTimeFieldSet", "DateTime Test");

       $datetime = new Elements\DateTimeElement("TestDateTime");
       $this->form->AddElement($datetime);        $this->form->CloseFieldSet();
    }


}

